package com.ss.android.topic.view;

import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;

import com.ss.android.action.b.ImpressionHelper;
import com.ss.android.action.b.b;
import com.ss.android.action.b.FeedViewHolder;
import com.ss.android.action.b.ImpressionRecorder;
import com.ss.android.article.browser.R;
import com.ss.android.common.app.LifeCycleMonitor;
import com.ss.android.k.a.a;
import java.util.ArrayList;
import java.util.List;

public abstract class c extends a implements
        AbsListView.RecyclerListener,
        com.ss.android.action.b.a,
        LifeCycleMonitor {
    public b a;
    private boolean c;
    private boolean d;
    private AbsListView e;

    public c() {

        this.c = true;
        this.d = true;
    }

    public final boolean a() {
        return this.c;
    }

    public final boolean a(int arg2, FeedViewHolder arg3) {
        return this.c;
    }

    public final List b() {
        List v0_2;
        Object v1 = null;
        if(this.e == null) {
            v0_2 = ((List)v1);
        }
        else {
            ArrayList v2 = new ArrayList();
            int v4 = this.e.getChildCount();
            int v3;
            for(v3 = 0; v3 < v4; ++v3) {
                Object v0_1 = this.e.getChildAt(v3).getTag(com.ss.android.article.browser.R.id.ab);
                if(!(v0_1 instanceof FeedViewHolder)) {
                    v0_1 = v1;
                }

                if(v0_1 != null) {
                    ((List)v2).add(v0_1);
                }
            }

            v0_2 = v2;
        }

        return ((List)v0_2);
    }

    public abstract void b(int arg1, FeedViewHolder arg2);

    public final void onDestroy() {
        if((this.a instanceof ImpressionRecorder)) {
            ImpressionHelper.getInstance().a(this.a, ((ImpressionRecorder)this.a).b);
        }
    }

    public final void onResume() {
        this.c = true;
        this.g();
        if(this.a != null) {
            this.a.a(((com.ss.android.action.b.a)this));
            this.d = false;
        }
    }

    public abstract b f();

    public final void onPause() {
        if(!this.d) {
            this.g();
            if(this.a != null) {
                this.a.b(((com.ss.android.action.b.a)this));
                this.d = true;
            }
        }

        this.c = false;
    }

    private void g() {
        if(this.a == null) {
            this.a = this.f();
        }
    }

    public View getView(int arg4, View arg5, ViewGroup arg6) {
        FeedViewHolder v0_1;
        int v2 = R.id.ab;
        this.e = (AbsListView) arg6;
        View v1 = super.getView(arg4, arg5, arg6);
        v0_1 = (FeedViewHolder) v1.getTag(v2);
        if(v0_1 == null) {
            v0_1 = new FeedViewHolder();
            v1.setTag(v2, v0_1);
        }

        this.b(arg4, v0_1);
        if(this.c) {
            this.g();
            if(this.a != null && v0_1 != null) {
                this.a.a(v0_1);
                this.d = false;
            }
        }

        return v1;
    }

    public final void onStop() {
    }

    public void onMovedToScrapHeap(View arg3) {
        Object v0 = arg3 != null ? arg3.getTag(com.ss.android.article.browser.R.id.ab) : null;
        if((v0 instanceof FeedViewHolder)) {
            this.g();
            if(this.a != null && v0 != null) {
                this.a.b(((FeedViewHolder)v0));
            }

            ((FeedViewHolder)v0).a();
        }
    }
}

